<template>
  <div>
    <FormPanel ref="form" :list="form" :cols="2" :labelWidth="90" :isSubmitBtn="false" @formChange="false" />
    <div>
      <LazyLoadTab :id="this.id" v-model="activeName" :tabMenus="menus"></LazyLoadTab>
    </div>
    <BaseDialog :visible="website" title="网点查询" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <websiteModel :rowData="websiteCode" @saveDialog="saveDialog" @closeDialog="website = false" />
    </BaseDialog>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
import { websiteModel } from './websiteModel';

export default {
  name: 'purchaseOrderDetile',
  mixins: [dictionary],
  props: ['id'],
  data() {
    return {
      form: this.createForm(),
      websiteCode: '',
      website: false,
      activeName: '单据信息',
      menus: [
        {
          title: '单据信息',
          path: 'part/partPurchase/purchaseOrderCheck/purchaseOrderInfo'
        },
        {
          title: '配件明细',
          path: 'part/partPurchase/purchaseOrderCheck/purchaseOrderPart'
        }
      ]
    };
  },
  mounted() {
    this.partAccount();
  },
  methods: {
    createForm() {
      return [
        {
          type: 'SELECT',
          label: '销售域',
          fieldName: 'salesDomainCode',
          itemList: this.createDictList('8059')
        },
        {
          type: 'INPUT',
          label: '网点',
          fieldName: 'websiteName',
          unitRender: () => {
            return <el-button icon="el-icon-search" onClick={this.websiteClick} />;
          }
        }
      ];
    },
    saveDialog(val) {
      this.form.find(x => x.fieldName === 'websiteName').initialValue = val.businessNetworkName;
      this.websiteCode = val.businessNetworkCode;
      this.website = false;
    },
    websiteClick() {
      this.websiteCode = this.form.find(x => x.fieldName === 'websiteName').initialValue;
      this.website = true;
    }
  }
};
</script>
